package com.rock.securityresearch.controller

import cats.effect.IO
import com.rock.securityresearch.equity.{HistoricalStockQuote, StockCode, Stocks}
import com.rock.securityresearch.service.StockService
import spark.{Request, Response}

import java.time.LocalDate

object StockController /*extends  Controller[IO]*/ {
//    override def getApis(): List[Api[IO]] = List(Api[IO](path = "/api/stock/:code", getStocksQuote))
//
//    private def getStocksQuote(req:Request, res:Response): IO[ApiResult[Map[String, List[HistoricalStockQuote]]]] = {
//        val code = req.params(":code").split(",").map(e => StockCode(e)).toList
//        val startDate = Option(req.queryParams("startDate")).map(e => LocalDate.parse(e)).getOrElse(LocalDate.now())
//        val endDate = Option(req.queryParams("endDate")).map(e => LocalDate.parse(e)).getOrElse(LocalDate.now())
//        val stocks = StockService.make(Stocks.make()).getQuotePrice(code, startDate, endDate)
//        stocks.map{ e =>
//            ApiResult(data = e)
//        }
//    }
//
//    private def getStockQuote(req:Request, res:Response): IO[ApiResult[List[HistoricalStockQuote]]] = ???

}
